package com.zks.example;

import org.junit.Test;

import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicStampedReference;

/**
* *
 * Salad class
 * 继承WeakReference，将Apple作为弱引用。
 *注意到时候回收的是Apple，而不是Salad
 * @author zks
* @date 2019/11/20 22:13
* @return
*/
public class Salad extends WeakReference<People> {

    public Salad(People people){
        super(people);
    }

    public static void main(String[] args) {
       // People people=new People("pe");
        Salad salad=new Salad(new People("pe"));
        System.out.println(salad.get());
        System.gc();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if(salad.get()==null){
            System.out.println("clear people");
        }
    }


    @Test
    public void te(){




    }
}
